//
//  XLBaseViewController.m
//  industry
//
//  Created by xl on 2020/11/11.
//  Copyright © 2020 Haier. All rights reserved.
//

#import "XLBaseViewController.h"

@interface XLBaseViewController ()
@property (nonatomic, assign) BOOL vipEnable;

@end

@implementation XLBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    if (self.vipEnable) {
        _cView.frame = self.view.frame;
        self.view = _cView;
    }
    self.view.backgroundColor = [UIColor whiteColor];
    if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]){
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}

#pragma mark - Public
//基于VIP模式
- (void)configVIPWithVCPrefix:(NSString *)name {
    self.vipEnable = YES;
    //presentor
    Class presenterClass = NSClassFromString([NSString stringWithFormat:@"XL%@Presenter", name]);
    if (presenterClass != NULL) {
        XLPresenter *presenter = (XLPresenter *)[presenterClass new];
        presenter.baseController = self;
        _presenter = presenter;
    }
    
    //interactor
    Class interactorClass = NSClassFromString([NSString stringWithFormat:@"XL%@Interactor", name]);
    if (interactorClass != NULL) {
        XLInteractor *interactor = (XLInteractor *)[interactorClass new];
        interactor.baseController = self;
        _interactor = interactor;
    }
    
    //view
    Class viewClass = NSClassFromString([NSString stringWithFormat:@"XL%@View", name]);
    if (viewClass != NULL) {
        XLView *cView = (XLView *)[viewClass new];
        cView.baseController = self;
        _cView = cView;
    }
    
}

@end
